﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GBU.Services.Pedometer
{
    public class StepDisplayer : IStepListener
    {
        private int MCount = 0;
        List<Listener> MListeners = new List<Listener>();

        public StepDisplayer()
        {
            NotifyListener();
        }

        public void OnStep()
        {
            MCount++;
            NotifyListener();
        }

        public void PassValue()
        {
           // throw new NotImplementedException();
        }


        public void SetSteps(int steps)
        {
            MCount = steps;
            NotifyListener();
        }


        public void AddListener(Listener l)
        {
            MListeners.Add(l);
        }

        public void NotifyListener()
        {
            //for (Listener listener : mListeners) {
            //    listener.stepsChanged((int)mCount);
            //}
            foreach (var listener in MListeners)
            {
                listener.StepsChanged(MCount);
            }
        }
    }

    public interface Listener
    {
        void StepsChanged(int value);
        void PassValue();
    }
}
